/* 
品牌管理相关的接口请求函数
*/
import request from '@/utils/request'
import type { TrademarkModel, TrademarkPageListModel, TrademarksModel } from './model/trademarkModel'

// 使用枚举来封装接口path
enum ApiPath {
  // GET /admin/product/baseTrademark/{page}/{limit}
  GetTrademarkPageList='/admin/product/baseTrademark',
  // POST /admin/product/baseTrademark/save
  SaveTrademark='/admin/product/baseTrademark/save',
  // PUT /admin/product/baseTrademark/update
  UpdateTrademark='/admin/product/baseTrademark/update',
  // DELETE /admin/product/baseTrademark/remove/{id}
  RemoveTrademark='/admin/product/baseTrademark/remove',
  // GET /admin/product/baseTrademark/getTrademarkList
  GetAllTrademarkList='/admin/product/baseTrademark/getTrademarkList',
}

// 获取所有品牌的列表
export const getAllTrademarkListApi = () => {
  return request.get<any, TrademarksModel>(ApiPath.GetAllTrademarkList)
}

// 获取品牌分页列表
export const getTrademarkPageListApi = (page: number, limit: number) => {
  return request.get<any, TrademarkPageListModel>(ApiPath.GetTrademarkPageList + `/${page}/${limit}`)
}
// 添加品牌
export const saveTrademarkApi = (tmName: string, logoUrl: string) => {
  return request.post<any, any>(ApiPath.SaveTrademark, {tmName, logoUrl})
}
export const saveTrademarkApi2 = (trademark: TrademarkModel) => {
  return request.post<any, any>(ApiPath.SaveTrademark, trademark)
}
// 修改品牌
export const updateTrademarkApi = (trademark: TrademarkModel) => {
  return request.put(ApiPath.UpdateTrademark, trademark)
}
// 删除品牌
export const removeTrademarkApi = (id: number) => {
  return request.delete(ApiPath.RemoveTrademark + `/${id}`)
}